package com.crm.system.service.impl.sys;

import com.crm.common.util.CommonUtils;
import com.crm.model.entity.sys.VersionUpgrade;
import com.crm.model.qo.sys.VersionUpgradeQO;
import com.crm.service.sys.VersionUpgradeDbService;
import com.crm.system.service.sys.VersionUpgradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author luojie
 * @date 2021/6/10 9:43
 */
@Service
public class VersionUpgradeServiceImpl implements VersionUpgradeService {

    @Autowired
    private VersionUpgradeDbService versionUpgradeDbService;

    /***
     * @Description:查询版本号
     * @Param:
     * @Author: luojie
     * @Date: 2021/6/10 13:53
     */
    @Override
    public VersionUpgrade getVersionUpgrade() {
        //CRM系统
        String sysId = "2";
        //测试版
        String versionType = "2";
        VersionUpgrade versionUpgrade = versionUpgradeDbService.getVersionUpgrade(sysId,versionType);
        return versionUpgrade;
    }

    /**
     * 添加版本信息
     * @param versionUpgradeQO 版本添加对象
     * @return
     */
    @Override
    public Boolean addVersionInfo(VersionUpgradeQO versionUpgradeQO) {
        VersionUpgrade versionUpgrade = new VersionUpgrade();
        versionUpgrade.setVersionId(CommonUtils.getGUID());
        versionUpgrade.setVersionCode(versionUpgradeQO.getVersionCode());
        versionUpgrade.setVersionType(versionUpgradeQO.getVersionType());
        versionUpgrade.setVersionDesc(versionUpgradeQO.getVersionDesc());
        //系统ID:1-OA系统；2-crm系统
        versionUpgrade.setSysId("2");
        versionUpgrade.setCreateTm(new Date());
        Boolean result = versionUpgradeDbService.addVersionInfo(versionUpgrade);
        return result;
    }
}
